package uk.ac.tees.aetoolkit;

import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.widget.RemoteViews;

/**
 * MemoWidget class used as the widget for the memo application.
 * 
 * @author Sohail Rahman, Mark Williamson, Robert Sheffield
 * 
 */
public class MemoWidget extends AppWidgetProvider {
	//default string to set as memo.
	String memo = "DEFAULT";

	/**
	 * on Update method to set the widget.
	 */
	@Override
	public void onUpdate(Context ctx, AppWidgetManager aWM, int[] appWidgetIds) {
		RemoteViews remoteViews = new RemoteViews(ctx.getPackageName(),
				R.layout.layout_widget);
		ComponentName watchWidget = new ComponentName(ctx, MemoWidget.class);
		remoteViews.setTextViewText(R.id.tv, getMemo());
		aWM.updateAppWidget(watchWidget, remoteViews);
	}

	/**
	 * setter method to set memo string.
	 * @param memo the string to set the memo as.
	 */
	public void setMemo(String memo) {
		this.memo = memo;
	}
	/**
	 * returns the memo string
	 * @return the string to be returned.
	 */
	public String getMemo() {
		return memo;
	}
}